﻿// 功能：Camera设备接口
// 描述：
// 作者：温伟鹏
// 日期：2010/9/2 14:30:08

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace MeizuSDK.COM
{
    internal struct PTIME
    {
        /// LONGLONG->__int64
        public long Time;

        /// ULONG->unsigned int
        public uint Numerator;

        /// ULONG->unsigned int
        public uint Denominator;
    }
    /// <summary>
    /// 预览帧数据信息
    /// </summary>
    internal struct PSTREAM_HEADER
    {
        /// ULONG->unsigned int
        public uint Size;

        /// ULONG->unsigned int
        public uint TypeSpecificFlags;

        PTIME PresentationTime;

        /// LONGLONG->__int64
        public long Duration;

        /// ULONG->unsigned int
        public uint FrameExtent;

        /// ULONG->unsigned int
        public uint DataUsed;

        /// PVOID->void*
        public System.IntPtr Data;

        /// ULONG->unsigned int
        public uint OptionsFlags;

        /// DWORD->unsigned int
        public uint Handle;
    }
    /// <summary>
    /// 照片大小枚举
    /// </summary>
    public enum PhotoSize
    {
        /// <summary>
        /// QXGA格式的照片
        /// </summary>
        QXGA = 0,
        /// <summary>
        /// UXGA格式的照片
        /// </summary>
        UXGA,
        /// <summary>
        /// XGA格式的照片
        /// </summary>
        XGA,
        /// <summary>
        /// VGA格式的照片
        /// </summary>
        VGA
    }
    /// <summary>
    /// 设置照相机亮度
    /// </summary>
    public enum BrightnessLevel
    {
        /// <summary>
        /// 1级亮度
        /// </summary>
        Level_1 = 0,
        /// <summary>
        /// 2级亮度
        /// </summary>
        Level_2,
        /// <summary>
        /// 3级亮度
        /// </summary>
        Level_3,
        /// <summary>
        /// 4级亮度
        /// </summary>
        Level_4,
        /// <summary>
        /// 5级亮度
        /// </summary>
        Level_5,
        /// <summary>
        /// 6级亮度
        /// </summary>
        Level_6
    }
    /// <summary>
    /// 拍照模式
    /// </summary>
    public enum CameraMode
    {
        /// <summary>
        /// 自动模式
        /// </summary>
        Auto = 0,
        /// <summary>
        /// 关闭模式
        /// </summary>
        Off,
        /// <summary>
        /// 晴天模式
        /// </summary>
        Sunny,
        /// <summary>
        /// 阴天模式
        /// </summary>
        Cloudy,
        /// <summary>
        /// 荧光灯模式
        /// </summary>
        Fluorescent,
        /// <summary>
        /// 白炽灯模式
        /// </summary>
        Incandescent
    }

    /// <summary>
    /// Camera设备接口
    /// </summary>
    [ComImport]
    [Guid("AA58DFE7-905F-43c7-A2CE-976B48CAC88C")]// IID
    [InterfaceType( ComInterfaceType.InterfaceIsIUnknown)]
    [ComVisible(true)]
    internal interface ICameraDeviceInterface
    {
        /// <summary>
        /// 初始化Camera设备
        /// 此接口为摄像头设备的初始化过程，一切对摄像头的操作都基于此接口的成功操作。
        /// 另外，在初始化前请保证当前无Overlay被创建。由于预览画面显示在WINDOW0层，所以GUI窗口背景色应为RGB(16,0,16)方能正确显示预览画面。
        /// </summary>
        /// <param name="hWnd">显示图像内容的窗口句柄</param>
        /// <returns>TRUE 成功  FALSE 失败</returns>
        bool InitDevice(IntPtr hWnd);
        /// <summary>
        /// 反初始化Camera设备，与InitDevice配合使用
        /// </summary>
        /// <returns></returns>
        bool UnInitDevice();
        /// <summary>
        /// 开始预览(初始摄像头时默认预览状态为开)。预览画面尺寸为VGA格式
        /// </summary>
        /// <returns>TRUE 成功  FALSE 失败</returns>
        bool StartPreview();
        /// <summary>
        /// 暂停预览
        /// </summary>
        /// <returns>TRUE 成功  FALSE 失败</returns>
        bool PausePreview();
        /// <summary>
        /// 是否绘制预览画面。
        /// 此接口主要可用来控制预览画面在当前窗口的绘制，
        /// 用户可根据自身窗口的一些特性来掌握预览画面的绘制时机
        /// </summary>
        /// <param name="isDraw"> true为绘制， false为不绘制</param>
        void IsDrawPreviewFrame(bool isDraw);
        /// <summary>
        /// 拍照
        /// </summary>
        /// <returns>true成功；false失败</returns>
        bool TakePhoto();
        /// <summary>
        /// 开始自动对焦
        /// </summary>
        /// <returns>true成功；false失败</returns>
        bool StartAF();
        /// <summary>
        /// 判断是否对焦完毕
        /// </summary>
        /// <returns>true成功；false失败</returns>
        bool IsAFEnd();
        /// <summary>
        /// 停止自动对焦
        /// </summary>
        /// <returns>true成功；false失败</returns>
        bool StopAF();
        /// <summary>
        /// 设置照片名字。在拍照前通过调用此接口设置照片的保存路径
        /// </summary>
        /// <param name="photoName">照片名</param>
        void SetPhotoName(string photoName);
        /// <summary>
        /// 获取照片名字。拍照完成后调用
        /// </summary>
        /// <returns>照片名（全路径）</returns>
        string GetPhotoName();
        /// <summary>
        /// 设置拍照尺寸
        /// </summary>
        /// <param name="sizeType">拍照尺寸。
        /// 查看PhotoSize枚举值，用户通过选取不同的枚举值来设置当前拍照尺寸。</param>
        /// <returns></returns>
        bool SetPhotoSize(int sizeType);
        /// <summary>
        /// 获取当前拍照尺寸
        /// </summary>
        /// <returns>PhotoSize枚举值</returns>
        int GetPhotoSize();
        /// <summary>
        /// 设置预览区域的透明值
        /// </summary>
        /// <param name="alphaValue">透明值,取值范围为0到15，共16级</param>
        void SetPreviewAreaAlphaValue(int alphaValue);
        /// <summary>
        /// 设置亮度
        /// </summary>
        /// <param name="level">亮度值</param>
        /// <returns>true成功；false失败</returns>
        bool SetBrightness(int level);
        /// <summary>
        /// 设置拍照模式
        /// </summary>
        /// <param name="mode">模式类型</param>
        /// <returns>true成功；false失败</returns>
        bool SetMode(int mode);
        /// <summary>
        /// 获取预览帧数据信息
        /// </summary>
        /// <returns></returns>
        PSTREAM_HEADER GetPreviewData();
        ///// <summary>
        ///// 获取预览帧格式信息
        ///// </summary>
        ///// <returns></returns>
        //BITMAPINFO GetPreviewDataInfo();
    }
}
